package com.workerhelping.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.Version;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.workerhelping.enums.IncomeCategoryEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("t_income")
public class Income implements Serializable {
    @TableId
    private Integer id;
    // 收入日期
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date incomeDate;
    // 年份
    private String year;
    // 收入来源
    private String source;
    // 发生金额
    private Double money;
    // 收入类别id
    private Integer icId;

    @TableField(select = false,exist = false)
    private String incomeCategory = null;

    public String getIncomeCategory() {
        return IncomeCategoryEnum.getCategoryName(this.icId);
    }

    public Income(Date incomeDate, String year, String source, Double money, Integer icId) {
        this.incomeDate = incomeDate;
        this.year = year;
        this.source = source;
        this.money = money;
        this.icId = icId;
    }
}
